package com.doit.day05

import scala.collection.mutable

object _06_map {
  def main(args: Array[String]): Unit = {
    val map1: Map[Int, String] = Map(1 -> "zss", 2 -> "lss")
    //用对偶元祖的方式
    val map2: Map[Int, String] = Map((1, "zss"), (2, "lss"))

    val maybeString: Option[String] = map1.get(4)

    //java中 getOrDefault
    val str: String = map1.getOrElse(2, "找不到")
    println(str)

    val intToString: mutable.HashMap[Int, String] = mutable.HashMap[Int, String]()
    intToString.put(1,"zss")
    intToString.put(1,"lss")
    intToString.put(2,"bao")
    val maybeString1: Option[String] = intToString.remove(4)
    if (maybeString1.isDefined){
      println(maybeString1.get)
    }else{
      println("没有这个key")
    }




    //如果是true 代表什么意思  太low了
/*    if(maybeString.isDefined){
      val value: String = maybeString.get
    }else{
      val value: String = maybeString.get
    }*/



  }

}
